package com.zito.health.controller;

import com.zito.health.common.annotations.ResponseResult;
import com.zito.health.common.result.VerifyResult;
import com.zito.health.entity.LaboratoryIncharge;
import com.zito.health.service.LaboratoryInchargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 实验室负责人
 * @author: gxt
 * @time: 2019/11/11 10:47
 */
@Slf4j
@ResponseResult
@RestController
@RequestMapping("/laboratoryIncharge")
public class LaboratoryInchargeController {

    @Autowired
    private LaboratoryInchargeService laboratoryInchargeService;

    @PostMapping()
    public VerifyResult save(LaboratoryIncharge laboratoryIncharge){
        VerifyResult verifyResult = new VerifyResult();
        if(laboratoryIncharge.getId()!=null){
            laboratoryInchargeService.update(laboratoryIncharge);
        }else {
            laboratoryIncharge =laboratoryInchargeService.save(laboratoryIncharge);
        }
        verifyResult.setMsg(String.valueOf(laboratoryIncharge.getId()));
        return verifyResult;
    }

    @GetMapping("/queryByLaboratoryId")
    public LaboratoryIncharge queryByLaboratoryId(Integer laboratoryId){
        LaboratoryIncharge param = new LaboratoryIncharge();
        param.setLaboratoryId(laboratoryId);
        LaboratoryIncharge laboratoryIncharge = laboratoryInchargeService.queryOne(param);
        return laboratoryIncharge;
    }

}
